<template>
    <h1>用户登录</h1>
    <el-row :gutter="20">
      <el-col :span="5"><div class="grid-content ep-bg-purple"></div></el-col>
      <el-col :span="10">
        <el-form :model="form" label-width="120px">
          <el-form-item label="用户名">
            <el-input v-model="user.username" />
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="user.password" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="login">登录</el-button>
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="5"><div class="grid-content ep-bg-purple"></div></el-col>
    </el-row>
  </template>
  
  <script>
  /* eslint-disable */
  // 单独引入ElMessageBox
  import { ElMessageBox } from 'element-plus'
  import axios from 'axios'
  
  export default {
    name: 'login',
    
    methods: {
      login() {
          axios.get("http://127.0.0.1:8001/user/login?userName=" + this.user.username + "&userPwd=" + this.user.password)
          .then(( {data} )=>{
            console.log("==data==");
            console.log(data);
            if(data == '登入成功'){
              this.$router.push("/main");
            }

          })
          .catch((error)=>{
            console.log(error);
          })
        
          
      }
    }
  }
  </script>
  
  <style>
  </style>
  